package com.reggie.service.impl;

import com.reggie.mapper.ShoppingCartMapper;
import com.reggie.pojo.ShoppingCart;
import com.reggie.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Autowired
    ShoppingCartMapper shoppingCartMapper;

    @Override
    public List<ShoppingCart> findAll(Long userId) {
        List<ShoppingCart> shoppingCarts = shoppingCartMapper.findAll(userId);
        return shoppingCarts;
    }

    @Override
    public boolean add(ShoppingCart shoppingCart) {
        if (shoppingCartMapper.add(shoppingCart)==1) return true;
        return false;
    }

    @Override
    public boolean edit(ShoppingCart shoppingCart) {
        if (shoppingCartMapper.edit(shoppingCart)==1) return true;
        return false;
    }

    @Override
    public ShoppingCart find(ShoppingCart shoppingCart) {
        ShoppingCart shoppingCart1 = shoppingCartMapper.find(shoppingCart);
        return shoppingCart1;
    }

    @Override
    public boolean delete(ShoppingCart shoppingCart) {
        if (shoppingCartMapper.delete(shoppingCart)>=1) return true;
        return false;
    }
}
